import time
from generator import generate_random, generate_sorted, generate_reversed, generate_duplicates
from alg import *

test_cases = [
    ("Random", generate_random(1000)),
    ("Sorted", generate_sorted(1000)),
    ("Reversed", generate_reversed(1000)),
    ("Duplicates", generate_duplicates(1000)),
    ("Empty", []),
    ("Single", [5])
]

algorithms = [
    ("Insertion Sort", insertion_sort),
    ("Bubble Sort", bubble_sort),
    ("Quick Sort", quick_sort),
    ("Heap Sort", heap_sort),
    ("Merge Sort", merge_sort),
    ("Shell Sort", shell_sort)
]

for case_name, data in test_cases:
    print(f"Test Case: {case_name}")
    expected = sorted(data)
    for algo_name, algo in algorithms:
        start_time = time.perf_counter()
        result = algo(data)
        elapsed = time.perf_counter() - start_time
        assert result == expected, f"{algo_name} failed on {case_name}"
        print(f"{algo_name}: {elapsed:.6f} seconds")
    print()